\(\int \frac {3+\tan (c+d x)}{2-\tan (c+d x)} \, dx\) [314]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 25 \[ \int \frac {3+\tan (c+d x)}{2-\tan (c+d x)} \, dx=x-\frac {\log (2 \cos (c+d x)-\sin (c+d x))}{d} \]

[Out]

x-ln(2*cos(d*x+c)-sin(d*x+c))/d

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 25, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.095, Rules used = {3612, 3611} \[ \int \frac {3+\tan (c+d x)}{2-\tan (c+d x)} \, dx=x-\frac {\log (2 \cos (c+d x)-\sin (c+d x))}{d} \]

[In]

Int[(3 + Tan[c + d*x])/(2 - Tan[c + d*x]),x]

[Out]

x - Log[2*Cos[c + d*x] - Sin[c + d*x]]/d

Rule 3611

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c/(b*f))
*Log[RemoveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d,
0] && NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]

Rule 3612

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c +
b*d)*(x/(a^2 + b^2)), x] + Dist[(b*c - a*d)/(a^2 + b^2), Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x]
 /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[a*c + b*d, 0]

Rubi steps \begin{align*} \text {integral}& = x-\int \frac {-1-2 \tan (c+d x)}{2-\tan (c+d x)} \, dx \\ & = x-\frac {\log (2 \cos (c+d x)-\sin (c+d x))}{d} \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(62\) vs. \(2(25)=50\).

Time = 0.06 (sec) , antiderivative size = 62, normalized size of antiderivative = 2.48 \[ \int \frac {3+\tan (c+d x)}{2-\tan (c+d x)} \, dx=\frac {\arctan (\tan (c+d x))}{d}+\frac {\log \left (5-4 (2-\tan (c+d x))+(2-\tan (c+d x))^2\right )}{2 d}-\frac {\log (2-\tan (c+d x))}{d} \]

[In]

Integrate[(3 + Tan[c + d*x])/(2 - Tan[c + d*x]),x]

[Out]

ArcTan[Tan[c + d*x]]/d + Log[5 - 4*(2 - Tan[c + d*x]) + (2 - Tan[c + d*x])^2]/(2*d) - Log[2 - Tan[c + d*x]]/d

Maple [A] (verified)

Time = 0.04 (sec) , antiderivative size = 33, normalized size of antiderivative = 1.32

method result size
norman \(x -\frac {\ln \left (-2+\tan \left (d x +c \right )\right )}{d}+\frac {\ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d}\) \(33\)
risch \(i x +x +\frac {2 i c}{d}-\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+\frac {3}{5}-\frac {4 i}{5}\right )}{d}\) \(33\)
parallelrisch \(\frac {2 d x +\ln \left (1+\tan ^{2}\left (d x +c \right )\right )-2 \ln \left (-2+\tan \left (d x +c \right )\right )}{2 d}\) \(33\)
derivativedivides \(\frac {-\ln \left (-2+\tan \left (d x +c \right )\right )+\frac {\ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(37\)
default \(\frac {-\ln \left (-2+\tan \left (d x +c \right )\right )+\frac {\ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(37\)

[In]

int((3+tan(d*x+c))/(2-tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

x-1/d*ln(-2+tan(d*x+c))+1/2/d*ln(1+tan(d*x+c)^2)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 44, normalized size of antiderivative = 1.76 \[ \int \frac {3+\tan (c+d x)}{2-\tan (c+d x)} \, dx=\frac {2 \, d x - \log \left (\frac {\tan \left (d x + c\right )^{2} - 4 \, \tan \left (d x + c\right ) + 4}{\tan \left (d x + c\right )^{2} + 1}\right )}{2 \, d} \]

[In]

integrate((3+tan(d*x+c))/(2-tan(d*x+c)),x, algorithm="fricas")

[Out]

1/2*(2*d*x - log((tan(d*x + c)^2 - 4*tan(d*x + c) + 4)/(tan(d*x + c)^2 + 1)))/d

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 39 vs. \(2 (19) = 38\).

Time = 0.09 (sec) , antiderivative size = 39, normalized size of antiderivative = 1.56 \[ \int \frac {3+\tan (c+d x)}{2-\tan (c+d x)} \, dx=\begin {cases} x - \frac {\log {\left (\tan {\left (c + d x \right )} - 2 \right )}}{d} + \frac {\log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} & \text {for}\: d \neq 0 \\\frac {x \left (\tan {\left (c \right )} + 3\right )}{2 - \tan {\left (c \right )}} & \text {otherwise} \end {cases} \]

[In]

integrate((3+tan(d*x+c))/(2-tan(d*x+c)),x)

[Out]

Piecewise((x - log(tan(c + d*x) - 2)/d + log(tan(c + d*x)**2 + 1)/(2*d), Ne(d, 0)), (x*(tan(c) + 3)/(2 - tan(c
)), True))

Maxima [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 35, normalized size of antiderivative = 1.40 \[ \int \frac {3+\tan (c+d x)}{2-\tan (c+d x)} \, dx=\frac {2 \, d x + 2 \, c + \log \left (\tan \left (d x + c\right )^{2} + 1\right ) - 2 \, \log \left (\tan \left (d x + c\right ) - 2\right )}{2 \, d} \]

[In]

integrate((3+tan(d*x+c))/(2-tan(d*x+c)),x, algorithm="maxima")

[Out]

1/2*(2*d*x + 2*c + log(tan(d*x + c)^2 + 1) - 2*log(tan(d*x + c) - 2))/d

Giac [A] (verification not implemented)

none

Time = 0.34 (sec) , antiderivative size = 36, normalized size of antiderivative = 1.44 \[ \int \frac {3+\tan (c+d x)}{2-\tan (c+d x)} \, dx=\frac {2 \, d x + 2 \, c + \log \left (\tan \left (d x + c\right )^{2} + 1\right ) - 2 \, \log \left ({\left | \tan \left (d x + c\right ) - 2 \right |}\right )}{2 \, d} \]

[In]

integrate((3+tan(d*x+c))/(2-tan(d*x+c)),x, algorithm="giac")

[Out]

1/2*(2*d*x + 2*c + log(tan(d*x + c)^2 + 1) - 2*log(abs(tan(d*x + c) - 2)))/d

Mupad [B] (verification not implemented)

Time = 7.68 (sec) , antiderivative size = 49, normalized size of antiderivative = 1.96 \[ \int \frac {3+\tan (c+d x)}{2-\tan (c+d x)} \, dx=-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-2\right )}{d}+\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,\left (\frac {1}{2}-\frac {1}{2}{}\mathrm {i}\right )}{d}+\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (\frac {1}{2}+\frac {1}{2}{}\mathrm {i}\right )}{d} \]

[In]

int(-(tan(c + d*x) + 3)/(tan(c + d*x) - 2),x)

[Out]

(log(tan(c + d*x) - 1i)*(1/2 - 1i/2))/d - log(tan(c + d*x) - 2)/d + (log(tan(c + d*x) + 1i)*(1/2 + 1i/2))/d